package com.das.mechanic_base.widget;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.das.mechanic_base.R;
import com.das.mechanic_base.base.X3BaseSelfBottomSheetDialog;
import com.das.mechanic_base.utils.X3ScreenUtils;
import com.umeng.analytics.MobclickAgent;

public class X3SelectLiveTypeDialog extends X3BaseSelfBottomSheetDialog implements View.OnClickListener {

    private TextView tv_other;
    private TextView tv_local;
    private TextView tv_cancel;
    private TextView tv_video;

    public X3SelectLiveTypeDialog(@NonNull Context context) {
        super(context);
    }

    @Override
    protected boolean getDialogCancel() {
        return false;
    }

    @Override
    protected int getDialogHeight() {
        return X3ScreenUtils.dipToPx(316, mContext);
    }

    @Override
    protected void initView() {
        tv_other = getView(R.id.tv_other);
        tv_local = getView(R.id.tv_local);
        tv_video = getView(R.id.tv_video);
        tv_cancel = getView(R.id.tv_cancel);
        tv_other.setOnClickListener(this);
        tv_local.setOnClickListener(this);
        tv_cancel.setOnClickListener(this);
        tv_video.setOnClickListener(this);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.x3_dialog_select_live_type;
    }

    @Override
    public void onClick(View v) {
        int id = v.getId();
        if (id == R.id.tv_other) {
            if (ionSelectClickListener != null) {
                ionSelectClickListener.iOnselectOther();
            }
            dismiss();
        } else if (id == R.id.tv_local) {
            if (ionSelectClickListener != null) {
                ionSelectClickListener.iOnselectLocal();
            }
            dismiss();
        } else if (id == R.id.tv_video) {
            if (ionSelectClickListener != null) {
                ionSelectClickListener.iOnselectUploadVideo();
            }
            dismiss();
        } else if (id == R.id.tv_cancel) {
            dismiss();
        }
    }

    IonSelectClickListener ionSelectClickListener;

    public interface IonSelectClickListener {
        void iOnselectOther();

        void iOnselectLocal();

        void iOnselectUploadVideo();
    }

    public void setIonSelectOnclick(IonSelectClickListener ionSelectClickListener) {
        this.ionSelectClickListener = ionSelectClickListener;
    }

    @Override
    protected void onStart() {
        super.onStart();
        MobclickAgent.onPageStart("直播/录播弹窗");
    }

    @Override
    public void dismiss() {
        super.dismiss();
        MobclickAgent.onPageEnd("直播/录播弹窗");
    }
}
